package basicCompiler;

import java.io.*;
import java.util.LinkedList;
import java.util.List;

public class Main {
	
	public static void main( String[] args){
		String inputFile = "input.txt";
		List<Node> ast = new LinkedList<Node>();
		
		try{
			BufferedReader in = new BufferedReader( new FileReader( inputFile));
			String line;
			while ((line = in.readLine()) != null) {
				Parser p = new Parser(line);
				ast.add(p.Parse());
			}
		} catch ( FileNotFoundException e) {
			System.out.println("Error: Could nout open file!" + inputFile);
			e.printStackTrace();
			System.exit(1);
		} catch ( IOException e) {
			System.out.println("Error: Could not read/close file!" + inputFile);
			e.printStackTrace();
			System.exit(1);
		}
		
		/* Output:
		 * <fisier_intrare>_pt (parse treeul)
		 * <fisier_intrare>_sv (semantic visitor)
		 * <fisier_intrare>_rv (result visitor)
		 */
		
		// Print Abstract Sytax Tree
		System.out.println("r");
		for (Node node: ast)
			node.display();
	}
}
